//
//  AppDelegate.swift
//  CLWeiNo
//
//  Created by DDC on 2017/10/10.
//  Copyright © 2017年 DDC. All rights reserved.
//

import UIKit
import UserNotifications
import SVProgressHUD
import AFNetworking
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        /// 初始化额外信息
        setUpAddition()
        
        /// 初始化window
        window = UIWindow()
        window?.backgroundColor = UIColor.white
        window?.rootViewController = CLLMainViewController()
        /// 窗口的可视化
        window?.makeKeyAndVisible()
        
        return true
    }


}

// MARK: - 设置额外信心
extension AppDelegate {
    func setUpAddition (){
        // 设置最小的提示框显示时间
        SVProgressHUD.setMinimumDismissTimeInterval(1)
        // 设置网络加载提示开启
        AFNetworkActivityIndicatorManager.shared().isEnabled = true
        // 设置允许授权通知
        if #available(iOS 10.0, *) {
            UNUserNotificationCenter.current().requestAuthorization(options: [.alert,.sound,.carPlay,.badge]) { (success, error) in
                // print("授权"+( success ? "成功" : "失败"))
            }
        } else {
            // Fallback on earlier versions --  iOS 10 以下
            let notifySetting = UIUserNotificationSettings(types: [.badge,.alert,.sound], categories: nil)
            UIApplication.shared.registerUserNotificationSettings(notifySetting)
        }
    }
}

